package com.shyroke.service.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shyroke.common.DateUtils;
import com.shyroke.entity.UserInfo;
import com.shyroke.mapper.UserInfoMapper;
import com.shyroke.service.UserInfoServiceI;

@Service
public class UserInfoServiceImpl implements UserInfoServiceI {

	@Autowired
	private UserInfoMapper userInfoMapper;
	
	@Override
	public void insert(UserInfo userInfo) {
		userInfo.setCreatTime(DateUtils.getFormatCurrenDate());
		userInfo.setTouxiangPath("touxiang.jpg");
		userInfoMapper.insert(userInfo);
	}

	@Override
	public UserInfo selectByUserId(Integer id) {
		return userInfoMapper.selectByUserId(id);
	}

	@Override
	public void update(UserInfo userInfo) {
		UserInfo uptUser=userInfoMapper.selectByUserId(userInfo.getUserid());
		userInfo.setId(uptUser.getId());
		userInfoMapper.updateByPrimaryKeySelective(userInfo);
	}

	@Override
	public void deleteByUserId(Integer userId) {
		UserInfo usreInfo=userInfoMapper.selectByUserId(userId);
		userInfoMapper.deleteByPrimaryKey(usreInfo.getId());
	}

}
